package com.coffeeloversupportlibrary.coffeelover.mercury.utils;

import java.util.concurrent.TimeUnit;

import okhttp3.Call;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;

/**
 * @author 盛守义
 * @createTime 2021/10/25 11:19
 * @projectName TurningCoffee
 * @className HttpUtils.java
 * @description TODO
 */
public class HttpUtils {

    private static final String BASEURL = "http://turing.gz2vip.91tunnel.com";  //"http://10.7.88.9:8003";//"http://10.7.90.92:8000";

    public void HttpUtils(){    }

    public Call getPostCall(RequestBody body, String baseurl,String url){
        OkHttpClient client = new OkHttpClient.Builder().readTimeout(10000, TimeUnit.MILLISECONDS).connectTimeout(10000, TimeUnit.MILLISECONDS).build();
        Request req = new Request.Builder().url(baseurl+url).post(body).build();
        Call call = client.newCall(req);
        return call;
    }

    public Call getGetCall(String baseurl, String url){
        OkHttpClient client = new OkHttpClient.Builder().readTimeout(5000, TimeUnit.MILLISECONDS).connectTimeout(5000, TimeUnit.MILLISECONDS).build();
        Request req = new Request.Builder().url(baseurl+url).get().build();
        Call call = client.newCall(req);
        return call;
    }

    public Call getCall(RequestBody body, String url){
        OkHttpClient client = new OkHttpClient.Builder().readTimeout(10000, TimeUnit.MILLISECONDS).connectTimeout(10000, TimeUnit.MILLISECONDS).build();
        Request req = new Request.Builder().url(BASEURL+url).post(body).build();
        Call call = client.newCall(req);
        return call;
    }

    public Call getCall(String url){
        OkHttpClient client = new OkHttpClient.Builder().readTimeout(5000, TimeUnit.MILLISECONDS).connectTimeout(5000, TimeUnit.MILLISECONDS).build();
        Request req = new Request.Builder().url(BASEURL+url).get().build();
        Call call = client.newCall(req);
        return call;
    }


}
